package com.chiaching.webmagic.domain.document;

import com.chiaching.webmagic.domain.constant.ElasticsearchCommonConstant;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;

/**
 * @email 1738870995@qq.com
 * @author: 何佳靖
 * @date: 2022/3/26 11:51
 */
@Data
@Document(indexName = "super_mall_good",shards = 2,replicas = 2)
public class GoodDocument {

    /**
     * 对应es里面的字段
     */
    public static final String field_img = "img";

    public static final String field_title ="title";

    public static final String field_price ="price";

    public static final String field_desc ="desc";

    public static final String field_createTime ="create_time";

    public static final String field_updatetime ="update_time";

    @Id
    private String id;

    @Field(name = GoodDocument.field_img,type = FieldType.Keyword)
    private String img;

    @Field(name = GoodDocument.field_title,type = FieldType.Text,analyzer = ElasticsearchCommonConstant.ik_analyzer,searchAnalyzer = ElasticsearchCommonConstant.ik_searchAnalyzer)
    private String title;

    @Field(name = GoodDocument.field_price)
    private String price;

    @Field(name = GoodDocument.field_desc)
    private String desc;

    @Field(name = GoodDocument.field_createTime,type = FieldType.Date,format = DateFormat.date_hour_minute_second,pattern = ElasticsearchCommonConstant.DATE_FORMT)
    private Date createTime;

    @Field(name = GoodDocument.field_updatetime,type = FieldType.Date,format = DateFormat.date_hour_minute_second,pattern = ElasticsearchCommonConstant.DATE_FORMT)
    private Date updateTime;
}
